package com.longlonggo.config;

import org.apache.log4j.Logger;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 * 错误页面配置
 * @author me@longlonggo.com
 * @version 100-000-000<br/>
 * 创建日期：2018年7月9日 <br/>
 * 历史修订：<br/>
 */
@Configuration
public class ErrorConfig implements EmbeddedServletContainerCustomizer{
	protected Logger logger = Logger.getLogger(this.getClass());


	@Override
	public void customize(ConfigurableEmbeddedServletContainer container) {
		logger.info("ErrorConfig");
		ErrorPage error400 = new ErrorPage(HttpStatus.BAD_REQUEST, "/templates/error/400.ftl");
		ErrorPage error404 = new ErrorPage(HttpStatus.NOT_FOUND, "/templates/error/404.ftl");	
		ErrorPage error500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500.do");	
		container.addErrorPages(error400, error404, error500);
	}
}
